<?php
namespace app\index\controller;
class Index
{
    public function index()
    {
       /*  //$arr = ["name"=>1,"age"=>20];
        return jsonp(url('index/getNext',array("id"=>1,"type"=>1))); */
        return  view();
    }
    
    public  function getNext($id=null,$type=null){
        header("Access-Control-Allow-Origin: *");
        if ($id&&$type){
            $res = db('src')->where("id>".$id." and type = ".$type)->find();
        }else{
            $res = db("src")->find();
        }
        if($res){
            return json($res);
        }else{
            return json(array("errmsg"=>"陛下，最后一张啦！"));
        }
       
    }
    public  function getPre($id=null,$type=null){
        header("Access-Control-Allow-Origin: *");
        if ($id&&$type){
            $res = db('src')->where("id<".$id." and type = ".$type)->find();
        }else{
            $res = db("src")->find();
        }
        if($res){
            return json($res);
        }else{
            return json(array("errmsg"=>"陛下，没有啦！"));
        }
         
    }
}